package com.xiaoge.listener;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.PayloadApplicationEvent;
import org.springframework.stereotype.Component;

/**
 * TODO
 *
 * @author <a href="mailto:1330137071@qq.com">Zhang Xiao</a>
 * @since
 */
//@Component
public class ZhangXiaoApplicationListener implements ApplicationListener {
	/**
	 * 事件监听器, 代码版
	 * @param event the event to respond to
	 */
	@Override
	public void onApplicationEvent(ApplicationEvent event) {
		// todo 获取我们自己发布的事件信息(自己发布的事件类型是PayloadApplicationEvent这个类型)
		if (event instanceof PayloadApplicationEvent) {
			PayloadApplicationEvent payloadApplicationEvent = (PayloadApplicationEvent) event;
			System.out.println(payloadApplicationEvent.getPayload());
		}

		System.out.println(event);
	}
}
